package com.tcy.netlogin;

import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;


public class MyDefaultHttpClient extends DefaultHttpClient
{
	public MyDefaultHttpClient()
	{
		super();
		this.getParams().setParameter(HttpConnectionParams.CONNECTION_TIMEOUT,5000);
		this.getParams().setParameter(HttpConnectionParams.SO_TIMEOUT,5000);
	}
	
	public MyDefaultHttpClient(boolean proxy)
	{
		super();
		if(proxy == true)
		{
			HttpHost proxyHost = new HttpHost("210.45.250.53", 3128); 
			this.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxyHost);
			CredentialsProvider credsProvider = new BasicCredentialsProvider(); 
			Credentials creds = new UsernamePasswordCredentials("proxyaci", "proxy311");   
	        credsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), creds);   
			this.setCredentialsProvider(credsProvider);
		}
		this.getParams().setParameter(HttpConnectionParams.CONNECTION_TIMEOUT,5000);
		this.getParams().setParameter(HttpConnectionParams.SO_TIMEOUT,5000);
	}
}